<template>
	<view class="content">
		<view class="text-brown padding-sm bg-black text-white">
			注:微信用户请在右上角选择 "在浏览器中打开" ，再进行认证
		</view>
		<view class="mask text-center">
			<image src="../../static/dakai.png" class="margin-top-sm" mode="aspectFit"></image>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				uid:null
			}
		},
		onLoad(ops) {
			if(ops.id!="" && ops.id!=null && ops.id!=undefined){
				this.uid=ops.id
				this.toAuth()
			}
		},
		methods: {
			toAuth(){
				let iswx=this.isweixin()
				if(iswx)return ;
				uni.showLoading({
					title:'正在跳转...'
				})
				var that=this;
				uni.request({
					url: that.app.apiHost+"/wxindex",
					method:'POST',
					header:{'Authorization':'bearer '+that.app.getAuthCode()},
					data:{id:that.uid},
					success:(res)=>{
						console.log(res.data);
						if(res.data.code==0){
							uni.hideLoading()
							window.location.href=res.data.alipayurl
						}else{
							that.app.showMsg(res.data.msg);
						}
					},
					fail(res) {
						console.log(res);
					}
				})
			},
			isweixin(){
				let userAgent=navigator.userAgent
				if(userAgent.includes("MicroMessenger")){
					return true;
				}else{
					return false;
				}
			}
		}
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}
	.mask{
		position: fixed;
		top: 0;
		bottom: 0;
		height: 100%;
	    width: 100%;
		background-color: #28282899;
	}

</style>
